package cn.edu.szpt.qqdemov3.fragments;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import cn.edu.szpt.qqdemov3.R;
import cn.edu.szpt.qqdemov3.adapters.QQPluginAdapter;
import cn.edu.szpt.qqdemov3.beans.QQPluginBean;

public class QQPluginFragment extends Fragment {
    private RecyclerView rvPlugin;
    private QQPluginAdapter adapter;
    private List<QQPluginBean> data;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=null;
        view = inflater.inflate(R.layout.activity_qqplugin,container,false);
        rvPlugin = view.findViewById(R.id.rvPlugin);

        data = new ArrayList<>();
        initialData();
        adapter = new QQPluginAdapter(getContext(),data);

        rvPlugin.setLayoutManager(new GridLayoutManager(getContext(),2));

        rvPlugin.setAdapter(adapter);
        return view;
    }

    private void initialData(){
        String[] company_names={"ZhiYuan Group","FDG娱乐","Blitzblaster软件公司","Snagon工作室"};
        int[] soft_icons = {R.drawable.flypigg,R.drawable.banana,R.drawable.traffic,R.drawable.bridgeme};
        String[] soft_names = {"Fly Pig","Banana","赛车","BridgeMe"};
        int[] soft_stars = {R.drawable.market_star10,R.drawable.market_star09,R.drawable.market_star08,
                R.drawable.market_star09};

        data.clear();
        for(int i=0;i<company_names.length;i++){
            QQPluginBean bean = new QQPluginBean(company_names[i],soft_icons[i],
                    soft_names[i],soft_stars[i]);
            data.add(bean);
        }
    }

}
